class Solution(object):
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        revNum = int(str(abs(x))[::-1])
        if revNum > 2147483647 or revNum < -2147483648:
            return 0
        return revNum if x>0 else -revNum